//
//  BaseTableViewCell.m
//  tableHeight
//
//  Created by siyue on 15/8/22.
//  Copyright (c) 2015年 siyue. All rights reserved.
//

#import "BaseTableViewCell.h"

#define DeviceBounds [[UIScreen mainScreen] bounds]
#define DeviceWidth CGRectGetWidth(DeviceBounds)
#define DeviceHeight CGRectGetHeight(DeviceBounds)

@implementation BaseTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

//获取高度
- (CGFloat)heightForCell:(UITableViewCell *)sizingCell {
    //CGSize size = [sizingCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
    return [self calculateHeightForConfiguredSizingCell:sizingCell];
}

//计算高度
- (CGFloat)calculateHeightForConfiguredSizingCell:(UITableViewCell *)sizingCell {
    sizingCell.bounds = CGRectMake(0.0f, 0.0f, DeviceWidth, CGRectGetHeight(sizingCell.bounds));
    [sizingCell setNeedsLayout];
    [sizingCell layoutIfNeeded];
    CGSize size = [sizingCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
    return size.height + 1.0f; // Add 1.0f for the cell separator height
}


@end
